/*
 ============================================================================
 Page		 : 165
 Name        : scores_in.c
 Date	     : 20210403
 Author      : Hbue 18060333
 Copyright   : Your copyright notice
 Description : 使用循环处理数组
 ============================================================================
 */

#include <stdio.h>
#define SIZE 10
#define PAR 72
int main(void)
{
	int score[SIZE];

	printf("Enter %d golf scores:\n", SIZE);
	for(int index = 0; index < SIZE; index++)
	{
		scanf("%d", &score[index]);					/* 读入10个分数 */
	}
	printf("The scores read in are as follows:\n");
	for(int index = 0; index < SIZE; index++)
	{
		printf("%5d", score[index]);				/* 验证输入 */
	}
	printf("\n");
	int sum = 0;
	for(int index = 0; index < SIZE; index++)
	{
		sum += score[index];						/* 求总分数 */
	}
	float average = 1.0 * sum / SIZE;				/* 求平均分 */
	printf("Sum of scores = %d, average = %.2f\n", sum, average);
	printf("That's a hardicap of %.0f.\n", average - PAR);

	return 0;
}
